#!/bin/bash


#step1: get the translations files from the image
#因为汉化，都是针对translations目录下的文件进行的，我们正式的镜像是基于 apache/superset:latest版本来的
#此处，直接跑起来一个容器，然后把容器里的文件拷贝出来做汉化处理

pwd_path=`pwd`

docker run -d --rm --name superset-prepare -v $pwd_path/translations:/tmp/translations  apache/superset

docker exec superset-prepare cp -r /app/superset/translations /tmp/translations

docker stop superset-prepare

# step2: rebuild the mo files
# refer to : https://superset.apache.org/docs/contributing/translations/

docker run --rm -v $pwd_path/translations/translations:/tmp/build -v $pwd_path/shell-in-container:/tmp/shell python-env:0.1 /tmp/shell/build-in-container.sh

# step3: move the resule mo file to the directory for image build
cp ./translations/translations/zh/LC_MESSAGES/messages.mo ../superset-image/
